
#ifndef CTKPLUGIN_MENUBAR_H
#define CTKPLUGIN_MENUBAR_H

#include <QMenuBar>
#include "service/event/ctkEventAdmin.h"
#include "service/event/ctkEventHandler.h"

class MenuBar : public QMenuBar, public ctkEventHandler
{
    Q_OBJECT
    Q_INTERFACES(ctkEventHandler)
public:
    MenuBar(ctkPluginContext *context, QWidget *parent = nullptr);
    ~MenuBar() override;
    void initMenu();
    QMenu *getMenu(const QString &name);

signals:
    void sig_insertMenu(const QJsonObject &obj);

protected:
    void handleEvent(const ctkEvent& event) override;

protected slots:
    void insertMenuAndActions(const QJsonObject &obj);
    void actionTriggered();

private:
    ctkPluginContext *context_;
    QStringList menu_descriptions_;
    QMap<QString, QMenu*> menu_map_;
    QMap<QString, QList<QAction *>> actions_map_;
};


#endif //CTKPLUGIN_MENUBAR_H
